home *** CD-ROM | disk | FTP | other *** search
- #ifndef __MAIN__
- #include "main.h"
- #endif
-
- //Globals
- Boolean gDone = false;
- SpeechChannel theSpeechChan = nil;
- Byte formingByte;
- Boolean inputBufferHalfByte;
-
- void main (void)
- {
- SpeechInfoStruct theSpeechInfo;
- EventRecord event;
- OSErr theErr = noErr;
- Boolean gotEvent = false;
- DriverRefNum proxyInRefNum, proxyOutRefNum;
- ToolBoxInit ();
-
- theErr = SpeakWelcome ();
- if (theErr == noErr) {
- theErr = ListenToUser (&theSpeechInfo);
- }
-
-
- inputBufferHalfByte = false;
- formingByte = 0;
-
- while (theErr == noErr && (gDone == false || SpeechBusy() != 0)) { //Don't quit if we're talking to you
- gotEvent = WaitNextEvent (everyEvent, &event, 6, nil);
- if (gotEvent) {
- switch (event.what)
- {
- case keyDown:
- gDone = true; //want to be able to quit if speech recognition isn't working
- break;
- case kHighLevelEvent :
- AEProcessAppleEvent (&event); //Handle speech recognition events
- break;
- case mouseUp:
- case mouseDown:
- case keyUp:
- case autoKey:
- case updateEvt:
- case diskEvt:
- case activateEvt:
- case osEvt:
- break;
- }
- }
- }
-
- theErr = SRCloseRecognitionSystem (theSpeechInfo.recogSystem);
- }
-
- OSErr SpeakWelcome (void)
- {
- OSErr theErr = noErr;
-
- theErr = GetNewSpeechChan (&theSpeechChan); //Set up a global speech channel
-
- return theErr;
- }
-
- OSErr ListenToUser (SpeechInfoPtr theSpeechInfo)
- {
- OSErr theErr = noErr;
-
- theSpeechInfo->ID = 'myID';
- theSpeechInfo->recogSystem = 0;
- theSpeechInfo->theRecognizer = 0;
- theSpeechInfo->languages = nil;
- theSpeechInfo->SpeechDoneUPP = nil;
- theSpeechInfo->attributes = 0;
-
- theErr = InitSpeechRecognition (theSpeechInfo);
-
- if (theErr == noErr) {
- theErr = OpenSpeechRecognition (theSpeechInfo);
- }
-
- if (theErr == noErr) {
- theErr = ConfigureRecognition (theSpeechInfo);
- }
-
- if (theErr == noErr) {
- theErr = GetNewRecognizer (theSpeechInfo);
- }
-
- if (theErr == noErr) {
- theErr = SetSpeechDoneAEHander (theSpeechInfo);
- }
-
- if (theErr == noErr) {
- theErr = InstallRecogAEHandler (theSpeechInfo);
- }
-
- if (theErr == noErr) {
- theErr = MakeNewLanguage (theSpeechInfo);
- }
-
- if (theErr == noErr) {
- theErr = SRStartListening (theSpeechInfo->theRecognizer);
- }
-
- return theErr;
- }
-
-
-